package Operation;

import Book.Book;
import Book.Bookshelf;

import java.util.Scanner;

public class backBookOperate implements IOOperation{

    @Override
    public void work(Bookshelf bookshelf) {
        System.out.println("归还图书........");
        Scanner s = new Scanner(System.in);
        System.out.println("请输入你要归还的图书：");
        String name = s.nextLine();
        Book[] books = bookshelf.getBookList();
        for (int i = 0; i < bookshelf.getUsedSize(); i++) {
            if(name.equals(books[i].getName())) {
                System.out.println("归还"+name+"成功！");
                books[i].setBorrow(false);
                return;
            }
        }

        System.out.println("归还失败。"+"馆里还没有这本 "+name+" 书");
    }
}
